﻿function dom(id) { return document.getElementById(id); }
var cur_index = 1;
var num = 4;
var settime;
function change_Menu() {

    for (var i = 1; i <= num; i++) {
        if (cur_index == i) {
            dom("con" + i).style.display = "block";
            dom("m" + i).className = "on" + i;
        } else {
            dom("con" + i).style.display = "none";
            dom("m" + i).className = "out" + i;
        }
    }
}

function conAction() {
    if (cur_index < 4) {
        cur_index++
    }
    else {
        cur_index = 1
    }
    change_Menu();
}

function startAction() {
    stopAction();
    settime = setInterval(conAction, 15000)
}

function stopAction() {
    clearInterval(settime);
}

function clickAction(num) {
    stopAction();
    cur_index = num;
    change_Menu();
}
function windowLocation() {
    var weishi = window.location.search.match(/src=tab_two/i);
    var shadu = window.location.search.match(/src=tab_three/i);
    var liulunqi = window.location.search.match(/src=tab_four/i);
    var wangdun = window.location.search.match(/src=tab_five/i);
    var jijiuxiang = window.location.search.match(/src=tab_six/i);
    var mipan = window.location.search.match(/src=tab_seven/i);
    var yinsi = window.location.search.match(/src=tab_eight/i);
    var shouji = window.location.search.match(/src=tab_nine/i);
    var baoxianxiang = window.location.search.match(/src=tab_ten/i);
    if (weishi) {
        dom("con1").style.display = "none";
        dom("con2").style.display = "block";
        dom("m1").className = "out1";
        dom("m2").className = "on2";
        cur_index = 2;
    } else if (shadu) {
        dom("con1").style.display = "none";
        dom("con3").style.display = "block";
        dom("m1").className = "out1";
        dom("m3").className = "on3";
        cur_index = 3;
    } else if (liulunqi || wangdun || jijiuxiang || mipan || yinsi || shouji || baoxianxiang) {
        dom("con1").style.display = "none";
        dom("con4").style.display = "block";
        dom("m1").className = "out1";
        dom("m4").className = "on4";
        cur_index = 4;
    } else { }
    if (wangdun) { dom("txt1").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/wd.css"; }
    else if (jijiuxiang) { dom("txt2").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/jijiuxiang.css"; }
    else if (mipan) { dom("txt3").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/mipan.css"; }
    else if (yinsi) { dom("txt4").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/yinsi.css"; }
    else if (shouji) { dom("txt5").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/shouji.css"; }
    else if (baoxianxiang) { dom("txt6").style.display = "block"; dom("addLink").href = "http://img.360.cn/images/2011/360/baoxianxiang.css"; }
    else { dom("txt").style.display = "block"; dom("addLink").href = ""; }
}
window.onload = function () {
    windowLocation();
    startAction();
    //alert(213);
}